Repository navigation
chore(sync): port private's components, canvas fixes and iOS work - #499
Conversation
* feat(components): add reusable components for people and agents A main is an element marked data-doop-component; an instance is full markup marked data-doop-instance, so frame consumers need no changes. Agents read and write the short <doop-use> form. Edits become the narrowest override, stale saves merge three-way, and main changes propagate through ordinary frame writes. Spec and research: .context/specs/components.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(components): address review findings on detach, nesting and sync - Detached instances, and those of a deleted component, keep a frozen copy of the component's CSS scoped to a marker of their own. - Enum variant rules survive extraction when the main lacks the attribute. - Nested instances can be changed by id, and their ids derive from owner and part, so saves stop rewriting them. - A slot on a component's root is read back. - Library sync walks the whole tree and carries head tags. - A stream that goes idle settles its components. - Instance controls respect locks; creating and placing components can be undone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(components): address second review pass on props, CSS and rollback - Prop names that <doop-use> keeps for itself are refused and never inferred. - A boolean prop keeps its default when it is also bound to an attribute. - Restoring a revision restores its head tags. - Selector matching and scoping read escaped identifiers, so compiled utility classes such as hover:bg-red survive extraction. - Each component's keyframes get their own name in the scoped stylesheet. - Slot content keeps its surrounding whitespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(components): note the write order and the Layers tab after the merge Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(components): close the review findings on the engine, tools and routes Engine: style/script children get part keys so an unchanged save is no override; slot and html-override content renders on a fresh stack (a Card in a Card's slot stays) with a depth bound; token and font blocks stay out of component CSS; nested-instance edits in a main land in the same write; a null part override is dropped; head tags a component brings are marked and never read as another main's; a part rendered as another tag keeps its tag. Tools and routes: the REST bodies are validated with the tools' zod shapes (head is not accepted); candidate and library scans take edit; every writing tool reports the frames it changed; the resident reads libraries as the requester; a failed element conversion leaves no main-less component; library names stay unique; the description field follows a collaborator's change. Propagation runs the font pass too, and deleting a main's frame releases its component. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(components): carry library faces on import and keep long import names apart An imported component brings the @font-face rules for families only its library canvas's fonts supply, since the target's font pass knows only its own library; freeName shortens a name at the limit before adding its suffix, so two imports never share one. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(components): carried library faces go before the component's own CSS Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(components): keep a sheet's leading @import ahead of carried faces Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(components): open the Components tab from the collapsed Layers rail Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * feat(components): place by drag or menu, delete from the panel, menu-only instance actions A component card no longer places on click: it is dragged onto the canvas (into the frame under the pointer, or as a new frame on the paper) or placed through its "…" menu, which also goes to the main, pulls a library update and deletes the component behind a confirm. The Design panel's component section keeps the props alone; go to main, reset and detach live in the element's context menu, now with "Reset this element" for an overridden part. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): hit turned frames where they are drawn for drops frameAtPoint turns the point into each frame's own axes before checking its bounds, so a component card or a comment pin dropped on a rotated frame lands in it, and a drop beside it on the paper does not. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(comments): pin a dropped comment in a turned frame's own axes Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 872be76a1725bf98c02248bbb3f644e89e1206bf)
* feat(components): rename a component from the editor The server already took a new name through PATCH and update_component, but nothing in the editor sent one. A component's card menu in the Components tab now has Rename, a double-click on its name edits it in place, and the main's Layers row renames the component. An instance's row stays read-only, so one copy's rename cannot rename every copy. Instances link by id and follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(components): rename a standalone main's component from its Layers row The standalone branch ran first, so the row renamed only the frame. A main's row now renames the component, and a standalone main's frame too when the server did not carry the name across (the frame's name differed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(components): give a standalone main's frame the saved name, without undo The frame now follows the name the server saved (it strips quotes and angle brackets) rather than the typed text, follows even when the component already had that name, and is written without an undo step, since the component rename it accompanies has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 43f74360d58fff1eb0ecde43f07d810d4792b132)
…for the rest (#487) * feat(agents): ask agents to style elements inline, with a stylesheet for the rest The editor reads and writes an element's style attribute, so a style written there is the one a person can change, move and copy reliably. The MCP guide, create_frame's description and the resident agent's system prompt now share one FRAME_STYLES section that says so and names what still belongs in a <style> block. Guidance only: nothing rejects or rewrites a stylesheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix(agents): keep a property that changes out of the style attribute An inline value outranks every stylesheet rule, so a hover, variant or media-query rule could never change a property whose resting value was written inline. The guidance now puts both forms in the stylesheet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 3bd1c7a9eeec24aad65922ecd7a2114a1b0a8a37)
…rtant (#484) * fix(canvas): let a style edit win over a stylesheet rule marked !important A design's own rule marked !important beats a plain inline declaration, so an edit from the Design panel, a scrub or a resize grip changed nothing on screen. The frame runtime now writes the edit as !important when a rule matching the element declares one of the edit's longhands that way. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix(canvas): see !important through logical properties, all, adopted sheets and selected text Review follow-ups: a rule naming the box side logically (inline-size) or through all now counts, sheets a design script adopted are scanned (the runtime's own excluded by identity), and an edit on selected words matches rules against a stand-in placed where the selection sits, since the copied run is detached when it is styled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit baea73faae24911ca2370561cf55400d5a349b2f)
…s whose frame goes (#467) * fix(rotation): drop drawings along a turned frame's axes and end turns whose frame goes A drawing dragged inside a turned frame wrote the pointer's raw world travel as its document left/top, so in a frame turned 90° a drag down moved it along the frame's y instead of its x. The drop now carries the drawing's centre through the source frame's turn onto the canvas and back through the destination's (`turnedDropRect`), for moves within, into, out of and between frames. A frame turn kept its window listeners after its frame left the view: a release after a peer deleted the frame, or after leaving the page or canvas, read the missing frame as unturned and saved 0° with an undo entry. The turn now cancels when its frame, page or canvas goes, and a release with no frame saves nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(rotation): carry standalone drops through a turned frame and end turns whose frame changes page Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(menus): expect the Cut item #468 added to the context menus Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit aae1d0101cbbbdf4644da920ac56b6e5dafd0298)
…ortcuts from inside frames (#411) * fix(canvas): keep the element panel through a frame drag and relay shortcuts from inside frames A press on a layer that cannot move (locked, or nothing movable under the pointer) falls back to dragging the frame, and letting go closed the element popovers together with the pick, so the HTML/Design panel vanished. A frame move now keeps the pick; a resize still lets go. After text editing the focus stays in the frame document, where the canvas never saw a key: the runtime now relays keydown/keyup to the page (not while editing, in a design's own field, or while a prototype plays), and keeps the canvas's Ctrl/⌘ chords from the frame's browser defaults. ⌘C / ⌘D also match with Caps Lock on. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(canvas): relay the newer chords from frames and focus the frame on purpose in the test Rebased onto main: the chord list the frame runtime keeps from its browser defaults gains ⌘A, ⌘[ / ⌘] (which would walk the frame's own history), ⌘B / ⌘I / ⌘U, ⌘⇧X and ⌘⇧7 / ⌘⇧8 (matched by code, as the page does). ⌘X joins ⌘C in staying the browser's, since both ride the native clipboard events now. Main already takes the focus back when a text edit ends (#341), so the regression puts the focus into the frame itself before pressing the keys. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): hear relayed keys only from a focused frame, never the deleting ones Greptile's review: a design's own script can post the relay's message, so FrameView replays a key only while the iframe holds the focus, and neither side carries ⌫ or Delete. ⌘C and ⌘X are not relayed at all, since the page cannot see text selected in the frame and would take the chord for its own selection. The runtime cancels Space (which would scroll the frame while the page pans) and the number pad's unshifted ⌘+. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): relay keys over a port a design's script cannot reach The runtime gets a MessagePort from FrameView on its ready signal, before any design HTML exists, and relays trusted key events over it alone; FrameView takes keys from that port and no longer from postMessage. A script in the frame has nothing to forge with: the port lives in the runtime's closure, its send is taken before the script runs, a synthetic event is untrusted, and a later port offer is ignored. The regression tries all three forgeries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): pin everything the key relay touches before a design script runs Reflect.apply, the port's send and the event getters are taken at bootstrap and used by reference, so a design script that replaces Function.prototype.call cannot fish the port out of the runtime's send, and one that redefines KeyboardEvent.prototype.key cannot turn the key the person pressed into another. FrameView checks the relayed payload's shape. The regression tries both patches. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): read the relay's field check through pinned natives too Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit bc046ac2de35edc3dad6ee7b82c916680b25d69c)
The ported action registry binds zoom to ⌘ on a Mac and leaves Ctrl+= alone there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit 58f62b86d9624493daa1d96b4fc9e822066e8a79)
The stale-paste case wrote external text through the async clipboard API and pasted at once. On the Linux runner the write's promise settles before the clipboard the paste event reads has it, so the paste still saw the canvas token and placed the old element (most CI runs since #468). The test now waits for readText to return the external text first. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 839f74c07f65d3fc260eaa0417b8b30cc3127a4c)
* feat(ios): show agents at work on their frames An agent streaming a design into a frame now gets a dashed ring pulsing in its colour and a "Claude is designing…" chip in the frame's title row, as on the web; an agent with a frame open gets a solid ring and its name. The model tracks frame:streaming and editing room messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ios): keep stacked agent chips on screen when fitting the board Fit now reserves a chip row above the frame titles, so a height-limited fit no longer clips a chip stacked above a narrow top-row frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 27b2c7942f53c58c0f4f49008ab5fb67ee71c8c3)
(cherry picked from commit 3d80daff1fad44eaf129c2b9599363fbaac821a8)
A tap picked the deepest element under the finger. Inside a text layer that was an inline run such as <b>, which Blitz gives no box, so the selection outline came back 0x0 and nothing highlighted. Pick the way the web runtime's probe does: the drawing the hit is part of, else the nearest element with a box. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 669027e83c36b303f82662db5c700be4cf77489b)
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> (cherry picked from commit 3b25a4e3a3b1e92d4a31357ff435d20be718f13d)
…as port - Components migration renumbered to 0052_components on this repo's journal (same SQL; a second drizzle-kit generate reports no schema changes). - No PSD import tool, PostHog tool set or requesterId on the resident run; library reads go by the run's payer. - familyKey added to shared/fonts.ts, which the components code needs. - ElementContextMenu imports useStore itself (it came in with the hosted cut). - Context menu expectations without Cut (doop#462 brings it); the components browser test serves the built app and skips the onboarding step. - The components spec keeps the model and decisions, not the product research. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed one fix on top: the multi-layer drag from doop#471 called |
[Critical impact] The PR reaches canvas component workflows, agent tools, iOS canvas behavior, and workspace billing. Fix component style preservation and import conflicts before merging. Findings
SummaryAdds reusable components across the editor, MCP tools, resident agents, and database.
|
| const rootDeclarations = [...vars, ...rootStyle] | ||
|
|
||
| /* @keyframes and @font-face the kept rules name, wherever they were declared */ | ||
| const fonts = usedFonts(`${ruleText} ${rootStyle.join(';')}`) |
There was a problem hiding this comment.
Instances lose fonts and animations
extractComponentCss ignores inline styles when choosing which @font-face and @keyframes blocks to keep. A main with style="font-family: Brand; animation: pulse 1s infinite" therefore loses those declarations when placed in another frame. Its instances show a fallback font and stop animating, even though the main looks correct.
Include inline declarations in these checks, and update inline animation names when renaming the keyframes.
| export function withDetachedCss(html: string, def: Pick<ComponentDef, 'id' | 'rev' | 'css'>): string { | ||
| const key = detachedKey(def) | ||
| if (!def.css.trim() || html.includes(`${DETACHED_CSS_ATTR}="${key}"`)) return html | ||
| const css = def.css | ||
| .replaceAll(`[${INSTANCE_ATTR}="${def.id}"]`, `[${DETACHED_ATTR}="${key}"]`) | ||
| .replaceAll(`__${def.id}`, `__${def.id}-${def.rev}`) | ||
| return insertIntoHead(html, `<style ${DETACHED_CSS_ATTR}="${key}">\n${css}\n</style>`) |
There was a problem hiding this comment.
Detach drops required stylesheets
withDetachedCss saves def.css but not the stylesheet links in def.head. Detaching the last instance then runs syncComponentHead, which removes those links because no linked instance needs them anymore. A component using an external font or stylesheet changes appearance when detached or deleted, despite the promise that its look stays the same.
Preserve the required head tags as unmanaged tags before removing the component link.
| const existing = store.getComponents(targetCanvasId).find((def) => def.id === origin.id) | ||
| if (existing) { | ||
| if (existing.source?.canvasId === sourceCanvasId && existing.source.rev === origin.rev) return changed | ||
| pullFrom(targetCanvasId, existing, origin, sourceCanvasId, actor) |
There was a problem hiding this comment.
Imports overwrite existing components
importDependencies treats every matching component ID as an existing import it can replace. Canvas copies deliberately keep these IDs. If a user edits a copied component and imports it into the original canvas, this branch replaces the original main and all its instances, then points its library source at the copy.
Only reuse an existing definition when it belongs to this source. Otherwise reject the conflict or assign fresh IDs and update the references.
| const saved = { ...def, mainFrameId: null, updatedAt: Date.now(), updatedBy: by } | ||
| store.saveComponent(canvas.id, saved) |
There was a problem hiding this comment.
prepareMains saves main-location changes without reporting them in changed. Removing a main, or restoring identical markup after its frame was deleted, sends no component update to connected editors. Their mainFrameId stays stale, so “Go to main” can open a frame without the main or report it missing after it has been restored.
Broadcast location-only changes without creating a new revision.
…tach, imports, main moves - An instance carries the @font-face and @Keyframes its main names in style attributes, not only in stylesheet rules; inline animations keep the keyframes name they were written with. - Detaching (or deleting) a component keeps the stylesheet links and scripts it brought, as the frame's own tags. - Importing refuses a component whose id this canvas already has from somewhere other than that library (a canvas and its copies share ids), checked for the whole dependency set before anything is written. - A main that only moves, or leaves its frame, is broadcast so open editors' "Go to main" follows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 972fe088648bea8c5046695773f622713bd42e07)
|
Greptile's four findings were real bugs in private's original components code. They're fixed in design-multiplayer#489, and I cherry-picked the same commit onto this branch. It includes one regression test per finding, and each test fails without its fix. |
* fix(icons): serve search_icons icons from Doop's origin Frames hotlinking api.iconify.design rendered blank in screenshots and exports on and off: the hosted renderer fetches outside pages itself, while Doop's own /a/ assets always loaded. search_icons now hands out /icons/<prefix>/<name>.svg, which the server fetches from Iconify (only its known customisations pass), caches in memory and serves like an /a/ SVG. The renderer also points a frame's existing Iconify hotlinks at Doop before loading it, so frames written before this render too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(icons): keep icons in the bucket, cap Iconify fetches, read them in-process for Figma Greptile review on #499: - Figma export read a Doop icon URL through fetchRemote, which refuses a private BETTER_AUTH_URL; it now reads the icon in-process. - Distinct colours or sizes bypass the cache, so a burst could start unbounded upstream fetches; at most 16 run and 64 wait, then 503 with Retry-After. Each icon is also kept in the bucket (icons/<sha256>.svg), so it is fetched from Iconify once ever and survives restarts and Iconify outages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(icons): type the stubbed fetch with the global Response Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(icons): name the provider in the icon URL and bucket folder /icons/iconify/<prefix>/<name>.svg, stored under iconify/, so another icon source can sit beside Iconify without a URL that frames already hold changing meaning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit ed3b3929cdc906588bc21ca3f878647c1c70fc1d)
Ports the shared work that landed on private since the last private → OSS sync. Commits are cherry-picked with
-xin private order, and onechore(oss)commit at the end keeps the hosted-only paths out.Ported:
<doop-use>, migration)!importantConflicts and adaptations:
0049_componentscollided with this repo's 0049–0051, so it is regenerated as0052_componentson this journal. The SQL is identical, and a seconddrizzle-kit generatereports "No schema changes".server/mcp.ts:get_framekeeps the image descriptions (frameSummary(f, images)) and adds the compact form andinstances. The PSD import tool is left out.server/resident.ts: the component tools are registered without the PostHog tool set. Libraries are read as the run's payer, because the private-onlyrequesterIddoesn't exist here.shared/fonts.ts: gainsfamilyKey, which the components code needs.ElementContextMenu: now importsuseStoreitself, since private brought that import in with Cut.drawingShapesBrowser.test.ts.componentsBrowser.test.ts: serves the built app (serveBuilt) and drops the onboarding step, which is hosted-only.hosted/onboardingi18n namespaces stay out, and the guide's export heading has no PSD.Checks: typecheck, lint and format:check are clean. All 15 test files the port touches pass (the components, rich-text, rotation, context menu and drawing browser suites among them), plus about 25 related files (i18n, MCP tools, registry, keys, frame runtime, Layers, fonts, billing). I didn't run the full suite locally.
🤖 Generated with Claude Code